package com.yamaikeji.quartz.task;

import com.yamaikeji.common.utils.StringUtils;
import com.yamaikeji.system.domain.plan.Plan;
import com.yamaikeji.system.service.plan.IPlanService;
import com.yamaikeji.system.service.plan.ITaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.util.List;

/**
 * 定时任务调度测试
 * 
 * @author yamaikeji
 */
@Component("createTask")
public class CreateTask {

    @Autowired
    private IPlanService pPlanService;

    @Autowired
    private ITaskService pTaskService;

    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void ryParams(String params) {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams() {
//        PTask pTask = new PTask();
//        pTask.setTaskTime(LocalDate.now().minusDays(1));
//        pTaskService.deleteAllPTask(pTask);
        Plan plan = new Plan();
        plan.setNowTime(LocalDate.now());
        plan.setSevenTime(LocalDate.now().plusDays(6));
        List<Plan> planList = pPlanService.selectSevenPlanList(plan);
        pTaskService.createTask(planList);
        System.out.println("执行无参方法");
    }
}
